<?php

namespace App\Rules;

use App\Tables\User;
use Illuminate\Contracts\Validation\Rule;

class MobileRule implements Rule
{
    protected $message;

    /**
     * Create a new rule instance.
     *
     */
    public function __construct()
    {
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        if (preg_match('/^1\d{10}$/', $value)) {

            return true;
        }

        $this->message = trans('validation.mobile', [$attribute]);
        return false;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return $this->message;
    }
}
